<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    pageContext.setAttribute("APP_PATH", request.getContextPath());
%>
<nav style="height: 40px" class="navbar navbar-expand-lg fixed-top bg-white">
    <button class="navbar-toggler p-0 border-0" type="button" data-toggle="offcanvas">
        <div>
            <c:choose>
                <c:when test="${not empty user.headimgurl}">
                    <img src="${user.headimgurl}" class="rounded-circle" width="40px" height="40px">
                </c:when>
                <c:otherwise>
                    <img src="${APP_PATH}/images/logo.jpg" class="rounded-circle" width="40px" height="40px">
                </c:otherwise>
            </c:choose>
        </div>
    </button>

    <div class="navbar-collapse offcanvas-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a class="nav-link text-danger" href="${APP_PATH}/home">主页</a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-dark" href="/blog-home">博客</a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-danger" href="${APP_PATH}/question-home">问答</a>
            </li>
            <c:choose>
                <c:when test="${not empty user}">
                    <%--不为空，已登录--%>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle text-danger" href="#" id="dropdown01" data-toggle="dropdown"
                           aria-haspopup="true" aria-expanded="false">${user.tel}</a>
                        <div class="dropdown-menu" aria-labelledby="dropdown01">
                            <a class="dropdown-item text-danger" href="${APP_PATH}/mine"><i class="fa fa-user"></i>个人中心</a>
                            <a class="dropdown-item text-danger" href="${APP_PATH}/blog-all"><i class="fa fa-bookmark"></i>我的博客</a>
                            <a class="dropdown-item text-danger" href="${APP_PATH}/question-all"><i class="fa fa-question"></i>问答管理</a>
                            <a class="dropdown-item text-danger" href="${APP_PATH}/user-message"><i class="fa fa-bell"></i>我的消息</a>
                            <a class="dropdown-item text-danger" href="${APP_PATH}/exit"><i class="fa fa-arrow-circle-left"></i>退出账号</a>
                        </div>
                    </li>
                </c:when>
                <c:otherwise>
                    <%--游客身份--%>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle text-danger" href="#" id="dropdown02" data-toggle="dropdown"
                           aria-haspopup="true" aria-expanded="false">游客</a>
                        <div class="dropdown-menu" aria-labelledby="dropdown02">
                            <a class="dropdown-item text-danger" href="${APP_PATH}/login">登录</a>
                            <a class="dropdown-item text-danger" href="${APP_PATH}/register">注册</a>
                        </div>
                    </li>
                </c:otherwise>
            </c:choose>
        </ul>
    </div>
</nav>
